package com.atguigu.lease.web.app.service.impl;

import com.atguigu.lease.model.entity.ApartmentInfo;
import com.atguigu.lease.model.entity.FacilityInfo;
import com.atguigu.lease.model.entity.GraphInfo;
import com.atguigu.lease.model.entity.LabelInfo;
import com.atguigu.lease.model.enums.ItemType;
import com.atguigu.lease.web.app.mapper.*;
import com.atguigu.lease.web.app.service.*;
import com.atguigu.lease.web.app.vo.apartment.ApartmentDetailVo;
import com.atguigu.lease.web.app.vo.apartment.ApartmentItemVo;
import com.atguigu.lease.web.app.vo.graph.GraphVo;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author liubo
 * @description 针对表【apartment_info(公寓信息表)】的数据库操作Service实现
 * @createDate 2023-07-26 11:12:39
 */
@Service
public class ApartmentInfoServiceImpl extends ServiceImpl<ApartmentInfoMapper, ApartmentInfo>
        implements ApartmentInfoService {

    @Autowired
    private ApartmentInfoMapper apartmentInfoMapper;

    @Autowired
    private LabelInfoService labelInfoService;
    @Autowired
    private GraphInfoService graphInfoService;
    @Autowired
    private FacilityInfoService facilityInfoService;

    @Override
    public ApartmentItemVo customByApartmentId(Long id) {
        ApartmentItemVo apartmentItemVo= apartmentInfoMapper.selectGetByApartmentId(id);
        List<LabelInfo> labelInfos = labelInfoService.listByApartmentId(id);
        List<GraphInfo> graphVos = graphInfoService.listByApartmentId(id, ItemType.APARTMENT);
        apartmentItemVo.setLabelInfoList(labelInfos);
        apartmentItemVo.setGraphVoList(graphVos);
        return apartmentItemVo;
    }

    @Override
    public ApartmentDetailVo customGetById(Long id) {
        ApartmentDetailVo apartmentDetailVo= apartmentInfoMapper.customSelectById(id);
        List<GraphVo> graphVoList = graphInfoService.listByItemTypeAndId(id,ItemType.APARTMENT);
        apartmentDetailVo.setGraphVoList(graphVoList);
        List<LabelInfo> labelInfoList = labelInfoService.listByApartmentId(id);
        apartmentDetailVo.setLabelInfoList(labelInfoList);
        List<FacilityInfo> facilityInfoList = facilityInfoService.listByApartmentId(id);
        apartmentDetailVo.setFacilityInfoList(facilityInfoList);
        return apartmentDetailVo;
    }
}




